package com.aqie.easy.array;

import java.util.Arrays;

/**
 * 561. 数组拆分 I
 */
public class ArrayPairSum {
    public int arrayPairSum(int[] nums) {
        // 数组排序 然后最小值相加
        Arrays.sort(nums);
        int sum = 0;
        for(int i = 0; i < nums.length; i+=2){
            sum += nums[i];
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] nums = {1,3,2};
        Arrays.sort(nums);
        System.out.println(Arrays.toString(nums));
    }
}
